<?php
require_once '../libraries/utilites/users.php';
?>

<link rel="stylesheet" type="text/css" href="public/css/style.css">

<!--<div id="pace-form">
    <div id="login-form">
        <h1 class="a">Login</h1>
        <div id="dau">Don't use Virb yet ?<a href="#">Take the tour</a> or <a href="#">join out</a></div>
        <form id="login" method="POST">           
            Username <input id="username" name="username" type="text" size="50px"></br>
            Password <input id="password" name="password" type="password" size="27px">
            <a href="#">Forgot your password</a></br>
            <input id="check" name="check" type="checkbox">Remember me on computer</br>
            <input id="supmit" name="supmit" type="submit" value="Login" size="10px">
        </form>
    </div>
</div>-->
<form method="POST">
    Usersname <input type="text" name="username"></br>
    Password <input type="password" name="password"></br>
    <input type="submit" name="submit" value="Login">
</form>
<?php
 if (isset($_POST['submit'])): ?>
    <?php
     $usersname = $_POST['username'];//kiem tra xem da nhap tren form login chua
     $password  = $_POST['password'];
     $isOk = FALSE;//la hien tai la nut submit chua dang nhap vao la false,dc la true
     $index = -1;//hien tai cho la -1;tuong ung voi cai chi so trong array
     //Kiem tra user
     for($i = 0;$i < count($users);$i ++){
         if((strcmp($users[$i]['username'],$usersname) == 0 ) &&
         (strcmp($users[$i]['password'],$password) == 0)){
             $isOk = TRUE;
             $index = $i;
         }
     }
     //Kiem Tra Dang Nhap
     if($isOk){
         //Dang Nhap Thanh Cong
         header("Location: http://localhost:82/nhathien-web1/film.php?uid=".$users[$index]['id']);
     }
 else {
     echo "Dang Nhap That Bai"  ;  
     }
?>
     <?php endif; ?>
